/*
 * @Author: 0x9DEFA478
 * @Date: 2022-01-22 23:03:13
 * @LastEditTime: 2022-03-28 00:08:28
 * @LastEditors: 0x9DEFA478
 * @Description: 
 * QQ:2652450237
 * ============================================================================================================================================
 * 
 * 
 * 
 *                                                                                               ************      ****************************
 *                                                                                             ************      ****************************  
 *                                                                                           ************      ****************************    
 *                                                                                         ************      ****************************      
 *                                                                                       ************      ************                        
 *                                                                                     ************      ************                          
 *                                                                                   ************      ************                            
 *                                                                                 ************      ************                              
 *                                                                               ************      ************                                
 *                                                                             ************      ************                                  
 *                                                                           ************      ************                                    
 *                                                                         ************      ************                                      
 *                                                                       ************      ************                                        
 *                                                                     ************      ************                                          
 *                                                                   ************      ************                                            
 *                                                                 ************      ************                                              
 *                                                               ************      ************                                                
 *                                                             ************      ************                                                  
 *                                                           ************      ************                                                    
 *                                                         ************      ************                                                      
 *                                                       ************      ************                                                        
 *                                                     ************      ************                                                          
 *                                                   ************      ************                                                            
 *                                                 ************      ************                                                              
 *                                               ************      ************                                                                
 *                                             ************      ************                                                                  
 *                                           ************      ************                                                                    
 *                                         ************      ************                                                                      
 *                                       ************      ************                                                                        
 *                                     ************      ************                                                                          
 *                                   ************      ************                                                                            
 *                                 ************      ************                                                                              
 *                               ************      ************                                                                                
 *                             ************      ************                                                                                  
 *                           ************      ************                                                                                    
 *                         ************      ************                                                                                      
 *       ****************************      ************                                                                                        
 *     ****************************      ************                                                                                          
 *   ****************************      ************                                                                                            
 * ****************************      ************                                                                                              
 * 
 * 
 * 
 * ============================================================================================================================================
 * 
 */
#include "./H_NES_Console.h"
#include "../ConstString/H_NES_ConstString.h"




#define vH_NES_CPU_NMIVector                                     0xFFFAU
#define vH_NES_CPU_ResetVector                                   0xFFFCU
#define vH_NES_CPU_IRQVector                                     0xFFFEU




static void ReadOpcodeException(H_NES_Console* Console,Huint16 ErrorAddress){
  oH_NES_Exception(Console,vH_NES_Result_FetchInstructionFail,H_NES_ConstString_ExceptionInstructionAccess,ErrorAddress);
}

//特定于读取操作码的操作宏 减少了不必要的分支
#define oH_NES_CPU_ReadOpcode(_in_Console,_in_Address,_out_Opcode) \
do{\
  if((_in_Address)>0x401FU){\
    _out_Opcode=_in_Console->Cartridge.PRG_Read(_in_Address,_in_Console);\
  }else{\
    if((_in_Address)<0x2000U){\
      _out_Opcode=((Hbyte*)_in_Console->CPU.Bus.RAM)[(_in_Address)&0x7FFU];\
    }else{\
      ReadOpcodeException(_in_Console,_in_Address);\
      for(;;){\
      }\
    }\
  }\
}while(0)

//特定于读取操作码的操作宏 减少了不必要的分支
#define oH_NES_CPU_Read16Opcode(_in_Console,_in_Address,_out_Opcode) \
do{\
  if((_in_Address)>0x401FU){\
    _out_Opcode=_in_Console->Cartridge.PRG_Read16(_in_Address,_in_Console);\
  }else{\
    if((_in_Address)<0x2000U){\
      _out_Opcode=((Hbyte*)_in_Console->CPU.Bus.RAM)[(_in_Address)&0x7FFU];\
      _out_Opcode|=((Huint16)((Hbyte*)_in_Console->CPU.Bus.RAM)[((_in_Address)+1U)&0x7FFU])<<8;\
    }else{\
      ReadOpcodeException(_in_Console,_in_Address);\
      for(;;){\
      }\
    }\
  }\
}while(0)




//通用读取
#define oH_NES_CPU_Read(_in_Console,_in_Address,_out_Value) \
do{\
  if((_in_Address)>0x401FU){\
    _out_Value=_in_Console->Cartridge.PRG_Read(_in_Address,_in_Console);\
  }else{\
    if((_in_Address)<0x2000U){\
      _out_Value=((Hbyte*)_in_Console->CPU.Bus.RAM)[(_in_Address)&0x7FFU];\
    }else{\
      _out_Value=H_NES_IO_Read(_in_Address,_in_Console);\
    }\
  }\
}while(0)


//通用写入
#define oH_NES_CPU_Write(_in_Console,_in_Address,_in_Value) \
do{\
  if((_in_Address)>0x401FU){\
    _in_Console->Cartridge.PRG_Write(_in_Value,_in_Address,_in_Console);\
  }else{\
    if((_in_Address)<0x2000U){\
      ((Hbyte*)_in_Console->CPU.Bus.RAM)[(_in_Address)&0x7FFU]=_in_Value;\
    }else{\
      H_NES_IO_Write(_in_Value,_in_Address,_in_Console);\
    }\
  }\
}while(0)




#define oH_NES_CPU_M_Imm(_in_Console,_in_NextPC,_out_M) \
do{\
  oH_NES_CPU_ReadOpcode(_in_Console,_in_NextPC,_out_M);\
}while(0)


#define oH_NES_CPU_M_GetAddress_ZeroPage(_in_Console,_in_NextPC,__temp_Zpg) \
do{\
  oH_NES_CPU_ReadOpcode(_in_Console,_in_NextPC,__temp_Zpg);\
}while(0)

#define oH_NES_CPU_M_ZeroPage(_in_Console,_in_NextPC,_out_M,__temp_Zpg) \
do{\
  oH_NES_CPU_M_GetAddress_ZeroPage(_in_Console,_in_NextPC,__temp_Zpg);\
  _out_M=((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg];\
}while(0)

#define oH_NES_CPU_M_Write_ZeroPage(_in_Console,_in_M,__temp_Zpg) \
do{\
  ((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg]=_in_M;\
}while(0)


#define oH_NES_CPU_M_GetAddress_ZeroPageX(_in_Console,_in_NextPC,__temp_Zpg) \
do{\
  oH_NES_CPU_ReadOpcode(_in_Console,_in_NextPC,__temp_Zpg);\
  __temp_Zpg+=_in_Console->CPU.Register.X;\
}while(0)

#define oH_NES_CPU_M_ZeroPageX(_in_Console,_in_NextPC,_out_M,__temp_Zpg) \
do{\
  oH_NES_CPU_M_GetAddress_ZeroPageX(_in_Console,_in_NextPC,__temp_Zpg);\
  _out_M=((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg];\
}while(0)

#define oH_NES_CPU_M_Write_ZeroPageX(_in_Console,_in_M,__temp_Zpg) \
do{\
  ((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg]=_in_M;\
}while(0)


#define oH_NES_CPU_M_GetAddress_ZeroPageY(_in_Console,_in_NextPC,__temp_Zpg) \
do{\
  oH_NES_CPU_ReadOpcode(_in_Console,_in_NextPC,__temp_Zpg);\
  __temp_Zpg+=_in_Console->CPU.Register.Y;\
}while(0)

#define oH_NES_CPU_M_ZeroPageY(_in_Console,_in_NextPC,_out_M,__temp_Zpg) \
do{\
  oH_NES_CPU_M_GetAddress_ZeroPageY(_in_Console,_in_NextPC,__temp_Zpg);\
  _out_M=((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg];\
}while(0)

#define oH_NES_CPU_M_Write_ZeroPageY(_in_Console,_in_M,__temp_Zpg) \
do{\
  ((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg]=_in_M;\
}while(0)


#define oH_NES_CPU_M_GetAddress_Abs(_in_Console,_in_NextPC,__temp_Abs) \
do{\
  oH_NES_CPU_Read16Opcode(_in_Console,_in_NextPC,__temp_Abs);\
}while(0)

#define oH_NES_CPU_M_Abs(_in_Console,_in_NextPC,_out_M,__temp_Abs) \
do{\
  oH_NES_CPU_M_GetAddress_Abs(_in_Console,_in_NextPC,__temp_Abs);\
  oH_NES_CPU_Read(_in_Console,__temp_Abs,_out_M);\
}while(0)

#define oH_NES_CPU_M_Write_Abs(_in_Console,_in_M,__temp_Abs) \
do{\
  oH_NES_CPU_Write(_in_Console,__temp_Abs,_in_M);\
}while(0)


#define oH_NES_CPU_M_GetAddress_AbsX(_in_Console,_in_NextPC,__temp_Abs,_out_ExtClock) \
do{\
  oH_NES_CPU_Read16Opcode(_in_Console,_in_NextPC,_out_ExtClock);\
  __temp_Abs=_out_ExtClock+_in_Console->CPU.Register.X;\
  if((__temp_Abs&0xFF00U)!=(_out_ExtClock&0xFF00U)){\
    _out_ExtClock=1U;\
  }else{\
    _out_ExtClock=0U;\
  }\
}while(0)

#define oH_NES_CPU_M_AbsX(_in_Console,_in_NextPC,_out_M,__temp_Abs,_out_ExtClock) \
do{\
  oH_NES_CPU_M_GetAddress_AbsX(_in_Console,_in_NextPC,__temp_Abs,_out_ExtClock);\
  oH_NES_CPU_Read(_in_Console,__temp_Abs,_out_M);\
}while(0)

#define oH_NES_CPU_M_Write_AbsX(_in_Console,_in_M,__temp_Abs) \
do{\
  oH_NES_CPU_Write(_in_Console,__temp_Abs,_in_M);\
}while(0)


#define oH_NES_CPU_M_GetAddress_AbsY(_in_Console,_in_NextPC,__temp_Abs,_out_ExtClock) \
do{\
  oH_NES_CPU_Read16Opcode(_in_Console,_in_NextPC,_out_ExtClock);\
  __temp_Abs=_out_ExtClock+_in_Console->CPU.Register.Y;\
  if((__temp_Abs&0xFF00U)!=(_out_ExtClock&0xFF00U)){\
    _out_ExtClock=1U;\
  }else{\
    _out_ExtClock=0U;\
  }\
}while(0)

#define oH_NES_CPU_M_AbsY(_in_Console,_in_NextPC,_out_M,__temp_Abs,_out_ExtClock) \
do{\
  oH_NES_CPU_M_GetAddress_AbsY(_in_Console,_in_NextPC,__temp_Abs,_out_ExtClock);\
  oH_NES_CPU_Read(_in_Console,__temp_Abs,_out_M);\
}while(0)

#define oH_NES_CPU_M_Write_AbsY(_in_Console,_in_M,__temp_Abs) \
do{\
  oH_NES_CPU_Write(_in_Console,__temp_Abs,_in_M);\
}while(0)


#define oH_NES_CPU_M_GetAddress_6ZeroPageX7(_in_Console,_in_NextPC,__temp_Zpg,__temp_Abs) \
do{\
  oH_NES_CPU_ReadOpcode(_in_Console,_in_NextPC,__temp_Zpg);\
  __temp_Zpg+=_in_Console->CPU.Register.X;\
  __temp_Abs=((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg];\
  __temp_Zpg++;\
  __temp_Abs|=((Huint16)((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg])<<8;\
}while(0)

#define oH_NES_CPU_M_6ZeroPageX7(_in_Console,_in_NextPC,_out_M,__temp_Zpg,__temp_Abs) \
do{\
  oH_NES_CPU_M_GetAddress_6ZeroPageX7(_in_Console,_in_NextPC,__temp_Zpg,__temp_Abs);\
  oH_NES_CPU_Read(_in_Console,__temp_Abs,_out_M);\
}while(0)

#define oH_NES_CPU_M_Write_6ZeroPageX7(_in_Console,_in_M,__temp_Abs) \
do{\
  oH_NES_CPU_Write(_in_Console,__temp_Abs,_in_M);\
}while(0)


#define oH_NES_CPU_M_GetAddress_6ZeroPage7Y(_in_Console,_in_NextPC,__temp_Zpg,__temp_Abs,_out_ExtClock) \
do{\
  oH_NES_CPU_ReadOpcode(_in_Console,_in_NextPC,__temp_Zpg);\
  _out_ExtClock=((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg];\
  __temp_Zpg++;\
  _out_ExtClock|=((Huint16)((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg])<<8;\
  __temp_Abs=_out_ExtClock+_in_Console->CPU.Register.Y;\
  if((__temp_Abs&0xFF00U)!=(_out_ExtClock&0xFF00U)){\
    _out_ExtClock=1U;\
  }else{\
    _out_ExtClock=0U;\
  }\
}while(0)

#define oH_NES_CPU_M_6ZeroPage7Y(_in_Console,_in_NextPC,_out_M,__temp_Zpg,__temp_Abs,_out_ExtClock) \
do{\
  oH_NES_CPU_M_GetAddress_6ZeroPage7Y(_in_Console,_in_NextPC,__temp_Zpg,__temp_Abs,_out_ExtClock);\
  oH_NES_CPU_Read(_in_Console,__temp_Abs,_out_M);\
}while(0)

#define oH_NES_CPU_M_Write_6ZeroPage7Y(_in_Console,_in_M,__temp_Abs) \
do{\
  oH_NES_CPU_Write(_in_Console,__temp_Abs,_in_M);\
}while(0)


#define oH_NES_CPU_M_GetAddress_6ZeroPage7(_in_Console,_in_NextPC,__temp_Zpg,__temp_Abs) \
do{\
  oH_NES_CPU_ReadOpcode(_in_Console,_in_NextPC,__temp_Zpg);\
  __temp_Abs=((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg];\
  __temp_Zpg++;\
  __temp_Abs|=((Huint16)((Hbyte*)_in_Console->CPU.Bus.RAM)[__temp_Zpg])<<8;\
}while(0)

#define oH_NES_CPU_M_6ZeroPage7(_in_Console,_in_NextPC,_out_M,__temp_Zpg,__temp_Abs) \
do{\
  oH_NES_CPU_M_GetAddress_6ZeroPage7(_in_Console,_in_NextPC,__temp_Zpg,__temp_Abs);\
  oH_NES_CPU_Read(_in_Console,__temp_Abs,_out_M);\
}while(0)

#define oH_NES_CPU_M_Write_6ZeroPage7(_in_Console,_in_M,__temp_Abs) \
do{\
  oH_NES_CPU_Write(_in_Console,__temp_Abs,_in_M);\
}while(0)




static int InstructionExecute_Unrealized(H_NES_Console* Console){
  Huint16 LastPC;
  Huint16 PC;
  Hbyte Opcode;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1;


  oH_NES_CPU_ReadOpcode(Console,LastPC,Opcode);
  oH_NES_Exception(Console,-1,"\r\nNES:未实现的指令0x%02X在0x%04X\r\n",Opcode,Console->CPU.Register.PC);
  for(;;){
    //未实现的指令
    (void)PC;
  }

  // Console->CPU.Register.PC=PC;//更新PC

  // return 2;
}

static int InstructionExecute_0x82(H_NES_Console* Console);
static int InstructionExecute_0xEA(H_NES_Console* Console);

static int InstructionExecute_0x00(H_NES_Console* Console){
  //BRK

  Huint16 LastPC;
  Huint16 PC;
  Hbyte SP;
  Hbyte P;
  Hbyte* Stack;

  P=Console->CPU.Register.P;
  SP=Console->CPU.Register.S;
  LastPC=Console->CPU.Register.PC;
  Stack=&((Hbyte*)Console->CPU.Bus.RAM)[0x100];

  PC=LastPC+2U;//下一条指令位置 (对于BRK PC额外加1)

  Stack[SP]=(Hbyte)(PC>>8);
  Stack[SP-(Hbyte)1U]=(Hbyte)PC;
  Stack[SP-(Hbyte)2U]=P|vH_NES_CPU_Register_P_PHP_BRK;
  SP-=3U;

  P|=vH_NES_CPU_Register_P_I;
  PC=Console->Cartridge.PRG_Read16(vH_NES_CPU_IRQVector,Console);//中断向量地址读取

  Console->CPU.Register.P=P;
  Console->CPU.Register.S=SP;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
}
static int InstructionExecute_0x01(H_NES_Console* Console){
  //ORA (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPageX7(Console,LastPC,M,Zpg,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x02(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x03(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SLO (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPageX7(Console,LastPC,M,Zpg,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_6ZeroPageX7(Console,M,Abs);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 8;
#endif
}
static int InstructionExecute_0x04(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x05(H_NES_Console* Console){
  //ORA Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x06(H_NES_Console* Console){
  //ASL Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_ZeroPage(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5;
}
static int InstructionExecute_0x07(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SLO Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_ZeroPage(Console,M,Zpg);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5;
#endif
}
static int InstructionExecute_0x08(H_NES_Console* Console){
  //PHP

  Huint16 PC;
  Hbyte SP;
  Hbyte* Stack;

  PC=Console->CPU.Register.PC;
  SP=Console->CPU.Register.S;
  Stack=&((Hbyte*)Console->CPU.Bus.RAM)[0x100];

  PC=PC+1U;//下一条指令位置

  Stack[SP]=Console->CPU.Register.P|vH_NES_CPU_Register_P_PHP_BRK;
  SP-=1U;

  Console->CPU.Register.S=SP;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x09(H_NES_Console* Console){
  //ORA #Oper

  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,M);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x0A(H_NES_Console* Console){
  //ASL A

  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  PC=Console->CPU.Register.PC;

  PC=PC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  A<<=1;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x0B(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x0C(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x0D(H_NES_Console* Console){
  //ORA Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x0E(H_NES_Console* Console){
  //ASL Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_Abs(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x0F(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SLO Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_Abs(Console,M,Abs);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
#endif
}

static int InstructionExecute_0x10(H_NES_Console* Console){
  //BPL Oper

  Huint16 ExtClock;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  ExtClock=0U;
  if((Console->CPU.Register.P&vH_NES_CPU_Register_P_N)==0U){
    LastPC++;
    oH_NES_CPU_ReadOpcode(Console,LastPC,M);
    LastPC=PC+M;
    if((M&0x80U)!=0U){
      LastPC+=0xFF00U;
    }
    if((LastPC&0xFF00U)!=(PC&0xFF00U)){
      ExtClock=2U;
    }else{
      ExtClock=1U;
    }
    PC=LastPC;
  }

  Console->CPU.Register.PC=PC;//更新PC

  return 2+ExtClock;
}
static int InstructionExecute_0x11(H_NES_Console* Console){
  //ORA (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPage7Y(Console,LastPC,M,Zpg,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5+ExtClock;
}
static int InstructionExecute_0x12(H_NES_Console* Console){
  //ORA (Zpg)

  return InstructionExecute_Unrealized(Console);
  // Hbyte Zpg;
  // Huint16 Abs;
  // Hbyte M;
  // Huint16 LastPC;
  // Huint16 PC;
  // Hbyte LastA;
  // Hbyte A;
  // Hbyte P;

  // LastA=Console->CPU.Register.A;
  // P=Console->CPU.Register.P;
  // LastPC=Console->CPU.Register.PC;

  // PC=LastPC+2U;//下一条指令位置

  // LastPC++;
  // oH_NES_CPU_M_6ZeroPage7(Console,LastPC,M,Zpg,Abs);

  // P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  // A=LastA|M;
  // if((A&0x80U)!=0x00U){
  //   P|=vH_NES_CPU_Register_P_N;
  // }else{
  //   if(A==0x00U){
  //     P|=vH_NES_CPU_Register_P_Z;
  //   }
  // }

  // Console->CPU.Register.A=A;
  // Console->CPU.Register.P=P;
  // Console->CPU.Register.PC=PC;//更新PC

  // return 5;
}
static int InstructionExecute_0x13(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SLO (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPage7Y(Console,LastPC,M,Zpg,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_6ZeroPage7Y(Console,M,Abs);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 8;
#endif
}
static int InstructionExecute_0x14(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x15(H_NES_Console* Console){
  //ORA Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x16(H_NES_Console* Console){
  //ASL Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_ZeroPageX(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x17(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SLO Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_ZeroPageX(Console,M,Zpg);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
#endif
}
static int InstructionExecute_0x18(H_NES_Console* Console){
  //CLC

  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P&=(~vH_NES_CPU_Register_P_C);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x19(H_NES_Console* Console){
  //ORA Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0x1A(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial NOP
  
  return InstructionExecute_0xEA(Console);
#endif
}
static int InstructionExecute_0x1B(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SLO Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_AbsY(Console,M,Abs);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
#endif
}
static int InstructionExecute_0x1C(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x1D(H_NES_Console* Console){
  //ORA Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0x1E(H_NES_Console* Console){
  //ASL Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_AbsX(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
}
static int InstructionExecute_0x1F(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SLO Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }
  M<<=1;
  A|=M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_AbsX(Console,M,Abs);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
#endif
}

static int InstructionExecute_0x20(H_NES_Console* Console){
  //JSR Abs
  
  Huint16 LastPC;
  Huint16 PC;
  Hbyte SP;
  Hbyte* Stack;
  
  SP=Console->CPU.Register.S;
  LastPC=Console->CPU.Register.PC;
  Stack=&((Hbyte*)Console->CPU.Bus.RAM)[0x100];

  PC=LastPC+2U;
  Stack[SP]=(Hbyte)(PC>>8);
  Stack[SP-(Hbyte)1U]=(Hbyte)PC;
  SP-=2U;

  LastPC++;
  oH_NES_CPU_Read16Opcode(Console,LastPC,PC);

  Console->CPU.Register.S=SP;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x21(H_NES_Console* Console){
  //AND (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPageX7(Console,LastPC,M,Zpg,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA&M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x22(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x23(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x24(H_NES_Console* Console){
  //BIT Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);


  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z));
  P|=M&(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V);
  if((Console->CPU.Register.A&M)==0U){
    P|=vH_NES_CPU_Register_P_Z;
  }


  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x25(H_NES_Console* Console){
  //AND Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA&M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x26(H_NES_Console* Console){
  //ROL Zpg

  Hbyte Zpg;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,LastM,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((P&vH_NES_CPU_Register_P_C)==0U){
    M=LastM<<1;
    if((M&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_N;
    }else{
      if(M==0x00U){
        P|=vH_NES_CPU_Register_P_Z;
      }
    }
    if((LastM&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_C;
    }
  }else{
    M=(LastM<<1)|0x01U;
    if((M&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_N;
    }
    if((LastM&0x80U)==0x00U){
      P&=(~vH_NES_CPU_Register_P_C);
    }
  }

  oH_NES_CPU_M_Write_ZeroPage(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5;
}
static int InstructionExecute_0x27(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x28(H_NES_Console* Console){
  //PLP

  Huint16 PC;
  Hbyte SP;
  Hbyte* Stack;

  PC=Console->CPU.Register.PC;
  SP=Console->CPU.Register.S;
  Stack=&((Hbyte*)Console->CPU.Bus.RAM)[0x100];

  PC=PC+1U;//下一条指令位置

  SP+=1U;
  Console->CPU.Register.P=Stack[SP]&(~vH_NES_CPU_Register_P_B_Msk);

  Console->CPU.Register.S=SP;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x29(H_NES_Console* Console){
  //AND #Oper

  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,M);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA&M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x2A(H_NES_Console* Console){
  //ROL A

  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  PC=Console->CPU.Register.PC;

  PC=PC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((P&vH_NES_CPU_Register_P_C)==0U){
    A=LastA<<1;
    if((A&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_N;
    }else{
      if(A==0x00U){
        P|=vH_NES_CPU_Register_P_Z;
      }
    }
    if((LastA&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_C;
    }
  }else{
    A=(LastA<<1)|0x01U;
    if((A&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_N;
    }
    if((LastA&0x80U)==0x00U){
      P&=(~vH_NES_CPU_Register_P_C);
    }
  }
  

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x2B(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x2C(H_NES_Console* Console){
  //BIT Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);


  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z));
  P|=M&(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V);
  if((Console->CPU.Register.A&M)==0U){
    P|=vH_NES_CPU_Register_P_Z;
  }
  

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x2D(H_NES_Console* Console){
  //AND Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA&M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x2E(H_NES_Console* Console){
  //ROL Abs

  Huint16 Abs;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,LastM,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((P&vH_NES_CPU_Register_P_C)==0U){
    M=LastM<<1;
    if((M&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_N;
    }else{
      if(M==0x00U){
        P|=vH_NES_CPU_Register_P_Z;
      }
    }
    if((LastM&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_C;
    }
  }else{
    M=(LastM<<1)|0x01U;
    if((M&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_N;
    }
    if((LastM&0x80U)==0x00U){
      P&=(~vH_NES_CPU_Register_P_C);
    }
  }

  oH_NES_CPU_M_Write_Abs(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x2F(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}

static int InstructionExecute_0x30(H_NES_Console* Console){
  //BMI Oper

  Huint16 ExtClock;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  ExtClock=0U;
  if((Console->CPU.Register.P&vH_NES_CPU_Register_P_N)!=0U){
    LastPC++;
    oH_NES_CPU_ReadOpcode(Console,LastPC,M);
    LastPC=PC+M;
    if((M&0x80U)!=0U){
      LastPC+=0xFF00U;
    }
    if((LastPC&0xFF00U)!=(PC&0xFF00U)){
      ExtClock=2U;
    }else{
      ExtClock=1U;
    }
    PC=LastPC;
  }

  Console->CPU.Register.PC=PC;//更新PC

  return 2+ExtClock;
}
static int InstructionExecute_0x31(H_NES_Console* Console){
  //AND (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPage7Y(Console,LastPC,M,Zpg,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA&M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5+ExtClock;
}
static int InstructionExecute_0x32(H_NES_Console* Console){
  //AND (Zpg)

  return InstructionExecute_Unrealized(Console);
  // Hbyte Zpg;
  // Huint16 Abs;
  // Hbyte M;
  // Huint16 LastPC;
  // Huint16 PC;
  // Hbyte LastA;
  // Hbyte A;
  // Hbyte P;

  // LastA=Console->CPU.Register.A;
  // P=Console->CPU.Register.P;
  // LastPC=Console->CPU.Register.PC;

  // PC=LastPC+2U;//下一条指令位置

  // LastPC++;
  // oH_NES_CPU_M_6ZeroPage7(Console,LastPC,M,Zpg,Abs);

  // P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  // A=LastA&M;
  // if((A&0x80U)!=0x00U){
  //   P|=vH_NES_CPU_Register_P_N;
  // }else{
  //   if(A==0x00U){
  //     P|=vH_NES_CPU_Register_P_Z;
  //   }
  // }

  // Console->CPU.Register.A=A;
  // Console->CPU.Register.P=P;
  // Console->CPU.Register.PC=PC;//更新PC

  // return 5;
}
static int InstructionExecute_0x33(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x34(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x35(H_NES_Console* Console){
  //AND Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA&M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x36(H_NES_Console* Console){
  //ROL Zpg,X

  Hbyte Zpg;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,LastM,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((P&vH_NES_CPU_Register_P_C)==0U){
    M=LastM<<1;
    if((M&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_N;
    }else{
      if(M==0x00U){
        P|=vH_NES_CPU_Register_P_Z;
      }
    }
    if((LastM&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_C;
    }
  }else{
    M=(LastM<<1)|0x01U;
    if((M&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_N;
    }
    if((LastM&0x80U)==0x00U){
      P&=(~vH_NES_CPU_Register_P_C);
    }
  }

  oH_NES_CPU_M_Write_ZeroPageX(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x37(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x38(H_NES_Console* Console){
  //SEC

  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P|=vH_NES_CPU_Register_P_C;

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x39(H_NES_Console* Console){
  //AND Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA&M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0x3A(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial NOP
  
  return InstructionExecute_0xEA(Console);
#endif
}
static int InstructionExecute_0x3B(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x3C(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x3D(H_NES_Console* Console){
  //AND Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA&M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0x3E(H_NES_Console* Console){
  //ROL Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,LastM,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((P&vH_NES_CPU_Register_P_C)==0U){
    M=LastM<<1;
    if((M&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_N;
    }else{
      if(M==0x00U){
        P|=vH_NES_CPU_Register_P_Z;
      }
    }
    if((LastM&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_C;
    }
  }else{
    M=(LastM<<1)|0x01U;
    if((M&0x80U)!=0x00U){
      P|=vH_NES_CPU_Register_P_N;
    }
    if((LastM&0x80U)==0x00U){
      P&=(~vH_NES_CPU_Register_P_C);
    }
  }

  oH_NES_CPU_M_Write_AbsX(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
}
static int InstructionExecute_0x3F(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}

static int InstructionExecute_0x40(H_NES_Console* Console){
  //RTI

  Huint16 PC;
  Hbyte SP;
  Hbyte P;
  Hbyte* Stack;

  SP=Console->CPU.Register.S;
  Stack=&((Hbyte*)Console->CPU.Bus.RAM)[0x100];

  SP+=3U;
  P=Stack[SP-(Hbyte)2U]&(~vH_NES_CPU_Register_P_B_Msk);
  PC=Stack[SP-(Hbyte)1U]+(((Huint16)Stack[SP])<<8);
  
  Console->CPU.Register.P=P;
  Console->CPU.Register.S=SP;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x41(H_NES_Console* Console){
  //EOR (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPageX7(Console,LastPC,M,Zpg,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA^M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x42(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x43(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x44(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x45(H_NES_Console* Console){
  //EOR Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA^M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x46(H_NES_Console* Console){
  //LSR Zpg

  Hbyte Zpg;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,LastM,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  M=LastM>>1;
  if(M==0x00U){
    P|=vH_NES_CPU_Register_P_Z;
  }
  if((LastM&0x01U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }

  oH_NES_CPU_M_Write_ZeroPage(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5;
}
static int InstructionExecute_0x47(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x48(H_NES_Console* Console){
  //PHA

  Huint16 PC;
  Hbyte SP;
  Hbyte* Stack;

  PC=Console->CPU.Register.PC;
  SP=Console->CPU.Register.S;
  Stack=&((Hbyte*)Console->CPU.Bus.RAM)[0x100];

  PC=PC+1U;//下一条指令位置

  Stack[SP]=Console->CPU.Register.A;
  SP-=1U;

  Console->CPU.Register.S=SP;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x49(H_NES_Console* Console){
  //EOR #Oper

  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,M);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA^M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x4A(H_NES_Console* Console){
  //LSR A

  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  PC=Console->CPU.Register.PC;

  PC=PC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=LastA>>1;
  if(A==0x00U){
    P|=vH_NES_CPU_Register_P_Z;
  }
  if((LastA&0x01U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x4B(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x4C(H_NES_Console* Console){
  //JMP Abs
  
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  LastPC++;
  oH_NES_CPU_Read16Opcode(Console,LastPC,PC);

  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x4D(H_NES_Console* Console){
  //EOR Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA^M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x4E(H_NES_Console* Console){
  //LSR Abs

  Huint16 Abs;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,LastM,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  M=LastM>>1;
  if(M==0x00U){
    P|=vH_NES_CPU_Register_P_Z;
  }
  if((LastM&0x01U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }

  oH_NES_CPU_M_Write_Abs(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x4F(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}

static int InstructionExecute_0x50(H_NES_Console* Console){
  //BVC Oper

  Huint16 ExtClock;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  ExtClock=0U;
  if((Console->CPU.Register.P&vH_NES_CPU_Register_P_V)==0U){
    LastPC++;
    oH_NES_CPU_ReadOpcode(Console,LastPC,M);
    LastPC=PC+M;
    if((M&0x80U)!=0U){
      LastPC+=0xFF00U;
    }
    if((LastPC&0xFF00U)!=(PC&0xFF00U)){
      ExtClock=2U;
    }else{
      ExtClock=1U;
    }
    PC=LastPC;
  }

  Console->CPU.Register.PC=PC;//更新PC

  return 2+ExtClock;
}
static int InstructionExecute_0x51(H_NES_Console* Console){
  //EOR (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPage7Y(Console,LastPC,M,Zpg,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA^M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5+ExtClock;
}
static int InstructionExecute_0x52(H_NES_Console* Console){
  //EOR (Zpg)

  return InstructionExecute_Unrealized(Console);
  // Hbyte Zpg;
  // Huint16 Abs;
  // Hbyte M;
  // Huint16 LastPC;
  // Huint16 PC;
  // Hbyte LastA;
  // Hbyte A;
  // Hbyte P;

  // LastA=Console->CPU.Register.A;
  // P=Console->CPU.Register.P;
  // LastPC=Console->CPU.Register.PC;

  // PC=LastPC+2U;//下一条指令位置

  // LastPC++;
  // oH_NES_CPU_M_6ZeroPage7(Console,LastPC,M,Zpg,Abs);

  // P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  // A=LastA^M;
  // if((A&0x80U)!=0x00U){
  //   P|=vH_NES_CPU_Register_P_N;
  // }else{
  //   if(A==0x00U){
  //     P|=vH_NES_CPU_Register_P_Z;
  //   }
  // }

  // Console->CPU.Register.A=A;
  // Console->CPU.Register.P=P;
  // Console->CPU.Register.PC=PC;//更新PC

  // return 5;
}
static int InstructionExecute_0x53(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x54(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x55(H_NES_Console* Console){
  //EOR Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA^M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x56(H_NES_Console* Console){
  //LSR Zpg,X

  Hbyte Zpg;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,LastM,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  M=LastM>>1;
  if(M==0x00U){
    P|=vH_NES_CPU_Register_P_Z;
  }
  if((LastM&0x01U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }

  oH_NES_CPU_M_Write_ZeroPageX(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x57(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x58(H_NES_Console* Console){
  //CLI

  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P&=(~vH_NES_CPU_Register_P_I);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x59(H_NES_Console* Console){
  //EOR Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA^M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0x5A(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial NOP
  
  return InstructionExecute_0xEA(Console);
#endif
}
static int InstructionExecute_0x5B(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x5C(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x5D(H_NES_Console* Console){
  //EOR Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  A=LastA^M;
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0x5E(H_NES_Console* Console){
  //LSR Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,LastM,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  M=LastM>>1;
  if(M==0x00U){
    P|=vH_NES_CPU_Register_P_Z;
  }
  if((LastM&0x01U)!=0x00U){
    P|=vH_NES_CPU_Register_P_C;
  }

  oH_NES_CPU_M_Write_AbsX(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
}
static int InstructionExecute_0x5F(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}

static int InstructionExecute_0x60(H_NES_Console* Console){
  //RTS

  Huint16 PC;
  Hbyte SP;
  Hbyte* Stack;

  SP=Console->CPU.Register.S;
  Stack=&((Hbyte*)Console->CPU.Bus.RAM)[0x100];

  SP+=2U;
  PC=Stack[SP-(Hbyte)1U]+(((Huint16)Stack[SP])<<8);
  PC+=1U;

  Console->CPU.Register.S=SP;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x61(H_NES_Console* Console){
  //ADC (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPageX7(Console,LastPC,M,Zpg,Abs);

  usA=(Huint16)LastA+M+(P&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA>0x00FFU){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((~(LastA^M))&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x62(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x63(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x64(H_NES_Console* Console){
  //STZ Zpg

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPage(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPage(Console,0U,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x65(H_NES_Console* Console){
  //ADC Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  usA=(Huint16)LastA+M+(P&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA>0x00FFU){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((~(LastA^M))&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x66(H_NES_Console* Console){
  //ROR Zpg

  Hbyte Zpg;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,LastM,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((P&vH_NES_CPU_Register_P_C)==0U){
    M=LastM>>1;
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
    if((LastM&0x01U)!=0x00U){
      P|=vH_NES_CPU_Register_P_C;
    }
  }else{
    M=(LastM>>1)|0x80U;
    P|=vH_NES_CPU_Register_P_N;
    if((LastM&0x01U)==0x00U){
      P&=(~vH_NES_CPU_Register_P_C);
    }
  }

  oH_NES_CPU_M_Write_ZeroPage(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5;
}
static int InstructionExecute_0x67(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x68(H_NES_Console* Console){
  //PLA

  Huint16 PC;
  Hbyte A;
  Hbyte P;
  Hbyte SP;
  Hbyte* Stack;

  P=Console->CPU.Register.P;
  PC=Console->CPU.Register.PC;
  SP=Console->CPU.Register.S;
  Stack=&((Hbyte*)Console->CPU.Bus.RAM)[0x100];

  PC=PC+1U;//下一条指令位置

  SP+=1U;
  A=Stack[SP];

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.S=SP;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x69(H_NES_Console* Console){
  //ADC #Oper

  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,M);

  usA=(Huint16)LastA+M+(P&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA>0x00FFU){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((~(LastA^M))&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x6A(H_NES_Console* Console){
  //ROR A

  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  PC=Console->CPU.Register.PC;

  PC=PC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((P&vH_NES_CPU_Register_P_C)==0U){
    A=LastA>>1;
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
    if((LastA&0x01U)!=0x00U){
      P|=vH_NES_CPU_Register_P_C;
    }
  }else{
    A=(LastA>>1)|0x80U;
    P|=vH_NES_CPU_Register_P_N;
    if((LastA&0x01U)==0x00U){
      P&=(~vH_NES_CPU_Register_P_C);
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x6B(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x6C(H_NES_Console* Console){
  //JMP (Abs)
  
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte HaftAddress;

  LastPC=Console->CPU.Register.PC;

  LastPC++;
  oH_NES_CPU_Read16Opcode(Console,LastPC,Abs);
  if((Abs&0x00FFU)==0x00FFU){
    oH_NES_CPU_ReadOpcode(Console,Abs,HaftAddress);
    PC=HaftAddress;
    Abs&=0xFF00U;
    oH_NES_CPU_ReadOpcode(Console,Abs,HaftAddress);
    PC|=(Huint16)HaftAddress<<8;
  }else{
    oH_NES_CPU_Read16Opcode(Console,Abs,PC);
  }
  

  Console->CPU.Register.PC=PC;//更新PC

  return 5;
}
static int InstructionExecute_0x6D(H_NES_Console* Console){
  //ADC Abs
  
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  usA=(Huint16)LastA+M+(P&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA>0x00FFU){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((~(LastA^M))&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x6E(H_NES_Console* Console){
  //ROR Abs

  Huint16 Abs;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,LastM,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((P&vH_NES_CPU_Register_P_C)==0U){
    M=LastM>>1;
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
    if((LastM&0x01U)!=0x00U){
      P|=vH_NES_CPU_Register_P_C;
    }
  }else{
    M=(LastM>>1)|0x80U;
    P|=vH_NES_CPU_Register_P_N;
    if((LastM&0x01U)==0x00U){
      P&=(~vH_NES_CPU_Register_P_C);
    }
  }

  oH_NES_CPU_M_Write_Abs(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x6F(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}

static int InstructionExecute_0x70(H_NES_Console* Console){
  //BVS Oper

  Huint16 ExtClock;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  ExtClock=0U;
  if((Console->CPU.Register.P&vH_NES_CPU_Register_P_V)!=0U){
    LastPC++;
    oH_NES_CPU_ReadOpcode(Console,LastPC,M);
    LastPC=PC+M;
    if((M&0x80U)!=0U){
      LastPC+=0xFF00U;
    }
    if((LastPC&0xFF00U)!=(PC&0xFF00U)){
      ExtClock=2U;
    }else{
      ExtClock=1U;
    }
    PC=LastPC;
  }

  Console->CPU.Register.PC=PC;//更新PC

  return 2+ExtClock;
}
static int InstructionExecute_0x71(H_NES_Console* Console){
  //ADC (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPage7Y(Console,LastPC,M,Zpg,Abs,ExtClock);

  usA=(Huint16)LastA+M+(P&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA>0x00FFU){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((~(LastA^M))&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5+ExtClock;
}
static int InstructionExecute_0x72(H_NES_Console* Console){
  //ADC (Zpg)

  return InstructionExecute_Unrealized(Console);
  // Hbyte Zpg;
  // Huint16 Abs;
  // Hbyte M;
  // Huint16 LastPC;
  // Huint16 PC;
  // Hbyte LastA;
  // Hbyte A;
  // Huint16 usA;
  // Hbyte P;

  // LastA=Console->CPU.Register.A;
  // P=Console->CPU.Register.P;
  // LastPC=Console->CPU.Register.PC;

  // PC=LastPC+2U;//下一条指令位置

  // LastPC++;
  // oH_NES_CPU_M_6ZeroPage7(Console,LastPC,M,Zpg,Abs);

  // usA=(Huint16)LastA+M+(P&vH_NES_CPU_Register_P_C);
  // P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  // A=(Hbyte)usA;
  // if(usA>0x00FFU){
  //   P|=vH_NES_CPU_Register_P_C;
  // }
  // if((A&0x80U)!=0x00U){
  //   P|=vH_NES_CPU_Register_P_N;
  // }else{
  //   if(A==0x00U){
  //     P|=vH_NES_CPU_Register_P_Z;
  //   }
  // }
  // if(((~(LastA^M))&(LastA^A)&0x80U)!=0x00U){
  //   P|=vH_NES_CPU_Register_P_V;
  // }

  // Console->CPU.Register.A=A;
  // Console->CPU.Register.P=P;
  // Console->CPU.Register.PC=PC;//更新PC

  // return 5;
}
static int InstructionExecute_0x73(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x74(H_NES_Console* Console){
  //STZ Zpg,X

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPageX(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPageX(Console,0U,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x75(H_NES_Console* Console){
  //ADC Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  usA=(Huint16)LastA+M+(P&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA>0x00FFU){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((~(LastA^M))&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x76(H_NES_Console* Console){
  //ROR Zpg,X

  Hbyte Zpg;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,LastM,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((P&vH_NES_CPU_Register_P_C)==0U){
    M=LastM>>1;
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
    if((LastM&0x01U)!=0x00U){
      P|=vH_NES_CPU_Register_P_C;
    }
  }else{
    M=(LastM>>1)|0x80U;
    P|=vH_NES_CPU_Register_P_N;
    if((LastM&0x01U)==0x00U){
      P&=(~vH_NES_CPU_Register_P_C);
    }
  }

  oH_NES_CPU_M_Write_ZeroPageX(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x77(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x78(H_NES_Console* Console){
  //SEI

  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P|=vH_NES_CPU_Register_P_I;

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x79(H_NES_Console* Console){
  //ADC Abs,Y
  
  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,M,Abs,ExtClock);
  
  usA=(Huint16)LastA+M+(P&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA>0x00FFU){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((~(LastA^M))&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0x7A(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial NOP
  
  return InstructionExecute_0xEA(Console);
#endif
}
static int InstructionExecute_0x7B(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x7C(H_NES_Console* Console){
  //JMP (Abs,X)
  
  return InstructionExecute_Unrealized(Console);
  // Huint16 Abs;
  // Huint16 LastPC;
  // Huint16 PC;

  // LastPC=Console->CPU.Register.PC;

  // LastPC++;
  // oH_NES_CPU_Read16Opcode(Console,LastPC,Abs);
  // Abs+=Console->CPU.Register.X;
  // oH_NES_CPU_Read16Opcode(Console,Abs,PC);

  // Console->CPU.Register.PC=PC;//更新PC

  // return 6;
}
static int InstructionExecute_0x7D(H_NES_Console* Console){
  //ADC Abs,X
  
  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  usA=(Huint16)LastA+M+(P&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA>0x00FFU){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((~(LastA^M))&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0x7E(H_NES_Console* Console){
  //ROR Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte LastM;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,LastM,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((P&vH_NES_CPU_Register_P_C)==0U){
    M=LastM>>1;
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
    if((LastM&0x01U)!=0x00U){
      P|=vH_NES_CPU_Register_P_C;
    }
  }else{
    M=(LastM>>1)|0x80U;
    P|=vH_NES_CPU_Register_P_N;
    if((LastM&0x01U)==0x00U){
      P&=(~vH_NES_CPU_Register_P_C);
    }
  }

  oH_NES_CPU_M_Write_AbsX(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
}
static int InstructionExecute_0x7F(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}

static int InstructionExecute_0x80(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial NOP

  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置
  
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
#endif
}
static int InstructionExecute_0x81(H_NES_Console* Console){
  //STA (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;

  A=Console->CPU.Register.A;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_6ZeroPageX7(Console,LastPC,Zpg,Abs);
  oH_NES_CPU_M_Write_6ZeroPageX7(Console,A,Abs);
  
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x82(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial NOP*t

  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  Console->CPU.Register.PC=PC;//更新PC

  return 2;
#endif
}
static int InstructionExecute_0x83(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SAX (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte X;

  A=Console->CPU.Register.A;
  X=Console->CPU.Register.X;
  M=A&X;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_6ZeroPageX7(Console,LastPC,Zpg,Abs);
  oH_NES_CPU_M_Write_6ZeroPageX7(Console,M,Abs);
  
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
#endif
}
static int InstructionExecute_0x84(H_NES_Console* Console){
  //STY Zpg

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte Y;

  Y=Console->CPU.Register.Y;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPage(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPage(Console,Y,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x85(H_NES_Console* Console){
  //STA Zpg

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;

  A=Console->CPU.Register.A;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPage(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPage(Console,A,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x86(H_NES_Console* Console){
  //STX Zpg

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte X;

  X=Console->CPU.Register.X;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPage(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPage(Console,X,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0x87(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SAX Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte X;

  A=Console->CPU.Register.A;
  X=Console->CPU.Register.X;
  M=A&X;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPage(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPage(Console,M,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 3;
#endif
}
static int InstructionExecute_0x88(H_NES_Console* Console){
  //DEY

  Huint16 PC;
  Hbyte Y;
  Hbyte P;

  Y=Console->CPU.Register.Y;
  P=Console->CPU.Register.P;
  PC=Console->CPU.Register.PC;

  PC=PC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  Y=Y-1U;
  if((Y&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(Y==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.Y=Y;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x89(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x8A(H_NES_Console* Console){
  //TXA

  Huint16 LastPC;
  Huint16 PC;
  Hbyte X;
  Hbyte P;

  X=Console->CPU.Register.X;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((X&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(X==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=X;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x8B(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x8C(H_NES_Console* Console){
  //STY Abs

  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte Y;

  Y=Console->CPU.Register.Y;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_Abs(Console,LastPC,Abs);
  oH_NES_CPU_M_Write_Abs(Console,Y,Abs);
  
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x8D(H_NES_Console* Console){
  //STA Abs

  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;

  A=Console->CPU.Register.A;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_Abs(Console,LastPC,Abs);
  oH_NES_CPU_M_Write_Abs(Console,A,Abs);
  
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x8E(H_NES_Console* Console){
  //STX Abs

  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte X;

  X=Console->CPU.Register.X;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_Abs(Console,LastPC,Abs);
  oH_NES_CPU_M_Write_Abs(Console,X,Abs);
  
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x8F(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SAX Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte X;

  A=Console->CPU.Register.A;
  X=Console->CPU.Register.X;
  M=A&X;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_Abs(Console,LastPC,Abs);
  oH_NES_CPU_M_Write_Abs(Console,M,Abs);
  
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
#endif
}

static int InstructionExecute_0x90(H_NES_Console* Console){
  //BCC Oper

  Huint16 ExtClock;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  ExtClock=0U;
  if((Console->CPU.Register.P&vH_NES_CPU_Register_P_C)==0U){
    LastPC++;
    oH_NES_CPU_ReadOpcode(Console,LastPC,M);
    LastPC=PC+M;
    if((M&0x80U)!=0U){
      LastPC+=0xFF00U;
    }
    if((LastPC&0xFF00U)!=(PC&0xFF00U)){
      ExtClock=2U;
    }else{
      ExtClock=1U;
    }
    PC=LastPC;
  }

  Console->CPU.Register.PC=PC;//更新PC

  return 2+ExtClock;
}
static int InstructionExecute_0x91(H_NES_Console* Console){
  //STA (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;

  A=Console->CPU.Register.A;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_6ZeroPage7Y(Console,LastPC,Zpg,Abs,ExtClock);
  oH_NES_CPU_M_Write_6ZeroPage7Y(Console,A,Abs);
  
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0x92(H_NES_Console* Console){
  //STA (Zpg)

  return InstructionExecute_Unrealized(Console);
  // Hbyte Zpg;
  // Huint16 Abs;
  // Huint16 LastPC;
  // Huint16 PC;
  // Hbyte A;

  // A=Console->CPU.Register.A;
  // LastPC=Console->CPU.Register.PC;

  // PC=LastPC+2U;//下一条指令位置

  // LastPC++;
  // oH_NES_CPU_M_GetAddress_6ZeroPage7(Console,LastPC,Zpg,Abs);
  // oH_NES_CPU_M_Write_6ZeroPage7(Console,A,Abs);
  
  // Console->CPU.Register.PC=PC;//更新PC

  // return 5;
}
static int InstructionExecute_0x93(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x94(H_NES_Console* Console){
  //STY Zpg,X

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte Y;

  Y=Console->CPU.Register.Y;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPageX(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPageX(Console,Y,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x95(H_NES_Console* Console){
  //STA Zpg,X

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;

  A=Console->CPU.Register.A;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPageX(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPageX(Console,A,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x96(H_NES_Console* Console){
  //STX Zpg,Y

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte X;

  X=Console->CPU.Register.X;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPageY(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPageY(Console,X,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0x97(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial SAX Zpg,Y

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte X;

  A=Console->CPU.Register.A;
  X=Console->CPU.Register.X;
  M=A&X;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPageY(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPageY(Console,M,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 4;
#endif
}
static int InstructionExecute_0x98(H_NES_Console* Console){
  //TYA

  Huint16 LastPC;
  Huint16 PC;
  Hbyte Y;
  Hbyte P;

  Y=Console->CPU.Register.Y;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((Y&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(Y==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=Y;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x99(H_NES_Console* Console){
  //STA Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;

  A=Console->CPU.Register.A;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_AbsY(Console,LastPC,Abs,ExtClock);
  oH_NES_CPU_M_Write_AbsY(Console,A,Abs);

  Console->CPU.Register.PC=PC;//更新PC

  return 5;
}
static int InstructionExecute_0x9A(H_NES_Console* Console){
  //TXS

  Huint16 LastPC;
  Huint16 PC;
  Hbyte X;

  X=Console->CPU.Register.X;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  Console->CPU.Register.S=X;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0x9B(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0x9C(H_NES_Console* Console){
  //STZ Abs

  return InstructionExecute_Unrealized(Console);
  // Huint16 Abs;
  // Huint16 LastPC;
  // Huint16 PC;

  // LastPC=Console->CPU.Register.PC;

  // PC=LastPC+3U;//下一条指令位置

  // LastPC++;
  // oH_NES_CPU_M_GetAddress_Abs(Console,LastPC,Abs);
  // oH_NES_CPU_M_Write_Abs(Console,0U,Abs);
  
  // Console->CPU.Register.PC=PC;//更新PC

  // return 4;
}
static int InstructionExecute_0x9D(H_NES_Console* Console){
  //STA Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;

  A=Console->CPU.Register.A;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_AbsX(Console,LastPC,Abs,ExtClock);
  oH_NES_CPU_M_Write_AbsX(Console,A,Abs);

  Console->CPU.Register.PC=PC;//更新PC

  return 5;
}
static int InstructionExecute_0x9E(H_NES_Console* Console){
  //STZ Zpg,X

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_GetAddress_ZeroPageX(Console,LastPC,Zpg);
  oH_NES_CPU_M_Write_ZeroPageX(Console,0U,Zpg);

  Console->CPU.Register.PC=PC;//更新PC

  return 5;
}
static int InstructionExecute_0x9F(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}

static int InstructionExecute_0xA0(H_NES_Console* Console){
  //LDY #Oper

  Huint16 LastPC;
  Huint16 PC;
  Hbyte Y;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,Y);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((Y&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(Y==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.Y=Y;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xA1(H_NES_Console* Console){
  //AND (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPageX7(Console,LastPC,A,Zpg,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0xA2(H_NES_Console* Console){
  //LDX #Oper

  Huint16 LastPC;
  Huint16 PC;
  Hbyte X;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,X);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((X&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(X==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.X=X;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xA3(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xA4(H_NES_Console* Console){
  //LDY Zpg

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte Y;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,Y,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((Y&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(Y==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.Y=Y;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0xA5(H_NES_Console* Console){
  //LDA Zpg

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,A,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0xA6(H_NES_Console* Console){
  //LDX Zpg

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte X;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,X,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((X&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(X==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.X=X;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0xA7(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xA8(H_NES_Console* Console){
  //TAY

  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.Y=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xA9(H_NES_Console* Console){
  //LDA #Oper

  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,A);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xAA(H_NES_Console* Console){
  //TAX

  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  A=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.X=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xAB(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xAC(H_NES_Console* Console){
  //LDY Abs

  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte Y;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,Y,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((Y&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(Y==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.Y=Y;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xAD(H_NES_Console* Console){
  //LDA Abs

  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,A,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xAE(H_NES_Console* Console){
  //LDX Abs

  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte X;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,X,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((X&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(X==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.X=X;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xAF(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}

static int InstructionExecute_0xB0(H_NES_Console* Console){
  //BCS Oper

  Huint16 ExtClock;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  ExtClock=0U;
  if((Console->CPU.Register.P&vH_NES_CPU_Register_P_C)!=0U){
    LastPC++;
    oH_NES_CPU_ReadOpcode(Console,LastPC,M);
    LastPC=PC+M;
    if((M&0x80U)!=0U){
      LastPC+=0xFF00U;
    }
    if((LastPC&0xFF00U)!=(PC&0xFF00U)){
      ExtClock=2U;
    }else{
      ExtClock=1U;
    }
    PC=LastPC;
  }

  Console->CPU.Register.PC=PC;//更新PC

  return 2+ExtClock;
}
static int InstructionExecute_0xB1(H_NES_Console* Console){
  //AND (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPage7Y(Console,LastPC,A,Zpg,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5+ExtClock;
}
static int InstructionExecute_0xB2(H_NES_Console* Console){
  //LDA (Zpg)

  return InstructionExecute_Unrealized(Console);
  // Hbyte Zpg;
  // Huint16 Abs;
  // Huint16 LastPC;
  // Huint16 PC;
  // Hbyte A;
  // Hbyte P;

  // P=Console->CPU.Register.P;
  // LastPC=Console->CPU.Register.PC;

  // PC=LastPC+2U;//下一条指令位置

  // LastPC++;
  // oH_NES_CPU_M_6ZeroPage7(Console,LastPC,A,Zpg,Abs);

  // P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  // if((A&0x80U)!=0x00U){
  //   P|=vH_NES_CPU_Register_P_N;
  // }else{
  //   if(A==0x00U){
  //     P|=vH_NES_CPU_Register_P_Z;
  //   }
  // }

  // Console->CPU.Register.A=A;
  // Console->CPU.Register.P=P;
  // Console->CPU.Register.PC=PC;//更新PC

  // return 5;
}
static int InstructionExecute_0xB3(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xB4(H_NES_Console* Console){
  //LDY Zpg,X

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte Y;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,Y,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((Y&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(Y==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.Y=Y;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xB5(H_NES_Console* Console){
  //LDA Zpg,X

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,A,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xB6(H_NES_Console* Console){
  //LDX Zpg,X

  Hbyte Zpg;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte X;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageY(Console,LastPC,X,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((X&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(X==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.X=X;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xB7(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xB8(H_NES_Console* Console){
  //CLV

  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P&=(~vH_NES_CPU_Register_P_V);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xB9(H_NES_Console* Console){
  //LDA Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,A,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0xBA(H_NES_Console* Console){
  //TSX

  Huint16 LastPC;
  Huint16 PC;
  Hbyte S;
  Hbyte P;

  S=Console->CPU.Register.S;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((S&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(S==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.X=S;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xBB(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xBC(H_NES_Console* Console){
  //LDY Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte Y;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,Y,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((Y&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(Y==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.Y=Y;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0xBD(H_NES_Console* Console){
  //LDA Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte A;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,A,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0xBE(H_NES_Console* Console){
  //LDX Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte X;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,X,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  if((X&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(X==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.X=X;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0xBF(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}

static int InstructionExecute_0xC0(H_NES_Console* Console){
  //CPY #Oper

  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usY;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,M);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usY=(Huint16)Console->CPU.Register.Y-M;
  if(usY<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usY&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usY==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xC1(H_NES_Console* Console){
  //CMP (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPageX7(Console,LastPC,M,Zpg,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0xC2(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial NOP*t

  return InstructionExecute_0x82(Console);
#endif
}
static int InstructionExecute_0xC3(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial DCP (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPageX7(Console,LastPC,M,Zpg,Abs);

  P&=(~(vH_NES_CPU_Register_P_C|vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_6ZeroPageX7(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 8;
#endif
}
static int InstructionExecute_0xC4(H_NES_Console* Console){
  //CPY Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usY;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usY=(Huint16)Console->CPU.Register.Y-M;
  if(usY<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usY&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usY==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0xC5(H_NES_Console* Console){
  //CMP Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0xC6(H_NES_Console* Console){
  //DEC Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_ZeroPage(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5;
}
static int InstructionExecute_0xC7(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial DCP Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_C|vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_ZeroPage(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5;
#endif
}
static int InstructionExecute_0xC8(H_NES_Console* Console){
  //INY

  Huint16 PC;
  Hbyte Y;
  Hbyte P;

  Y=Console->CPU.Register.Y;
  P=Console->CPU.Register.P;
  PC=Console->CPU.Register.PC;

  PC=PC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  Y=Y+1U;
  if((Y&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(Y==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.Y=Y;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xC9(H_NES_Console* Console){
  //CMP #Oper

  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,M);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xCA(H_NES_Console* Console){
  //DEX

  Huint16 PC;
  Hbyte X;
  Hbyte P;

  X=Console->CPU.Register.X;
  P=Console->CPU.Register.P;
  PC=Console->CPU.Register.PC;

  PC=PC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  X=X-1U;
  if((X&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(X==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.X=X;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xCB(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xCC(H_NES_Console* Console){
  //CPY Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usY;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usY=(Huint16)Console->CPU.Register.Y-M;
  if(usY<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usY&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usY==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xCD(H_NES_Console* Console){
  //CMP Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xCE(H_NES_Console* Console){
  //DEC Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_Abs(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0xCF(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial DCP Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_C|vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_Abs(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
#endif
}

static int InstructionExecute_0xD0(H_NES_Console* Console){
  //BNE Oper

  Huint16 ExtClock;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  ExtClock=0U;
  if((Console->CPU.Register.P&vH_NES_CPU_Register_P_Z)==0U){
    LastPC++;
    oH_NES_CPU_ReadOpcode(Console,LastPC,M);
    LastPC=PC+M;
    if((M&0x80U)!=0U){
      LastPC+=0xFF00U;
    }
    if((LastPC&0xFF00U)!=(PC&0xFF00U)){
      ExtClock=2U;
    }else{
      ExtClock=1U;
    }
    PC=LastPC;
  }

  Console->CPU.Register.PC=PC;//更新PC

  return 2+ExtClock;
}
static int InstructionExecute_0xD1(H_NES_Console* Console){
  //CMP (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPage7Y(Console,LastPC,M,Zpg,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5+ExtClock;
}
static int InstructionExecute_0xD2(H_NES_Console* Console){
  //CMP (Zpg)

  return InstructionExecute_Unrealized(Console);
  // Huint16 ExtClock;
  // Hbyte Zpg;
  // Hbyte M;
  // Huint16 LastPC;
  // Huint16 PC;
  // Huint16 usA;
  // Hbyte P;

  // P=Console->CPU.Register.P;
  // LastPC=Console->CPU.Register.PC;

  // PC=LastPC+3U;//下一条指令位置

  // LastPC++;
  // oH_NES_CPU_M_6ZeroPage7(Console,LastPC,M,Zpg,ExtClock);

  // P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  // usA=(Huint16)Console->CPU.Register.A-M;
  // if(usA<0x0100U){
  //   P|=vH_NES_CPU_Register_P_C;
  // }
  // if((usA&0x0080U)!=0U){
  //   P|=vH_NES_CPU_Register_P_N;
  // }else{
  //   if(usA==0U){
  //     P|=vH_NES_CPU_Register_P_Z;
  //   }
  // }

  // Console->CPU.Register.P=P;
  // Console->CPU.Register.PC=PC;//更新PC

  // return 5+ExtClock;
}
static int InstructionExecute_0xD3(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial DCP (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPage7Y(Console,LastPC,M,Zpg,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_C|vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_6ZeroPage7Y(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 8;
#endif
}
static int InstructionExecute_0xD4(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xD5(H_NES_Console* Console){
  //CMP Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xD6(H_NES_Console* Console){
  //DEC Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_ZeroPageX(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0xD7(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial DCP Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_C|vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_ZeroPageX(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
#endif
}
static int InstructionExecute_0xD8(H_NES_Console* Console){
  //CLD

  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P&=(~vH_NES_CPU_Register_P_D);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xD9(H_NES_Console* Console){
  //CMP Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0xDA(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial NOP
  
  return InstructionExecute_0xEA(Console);
#endif
}
static int InstructionExecute_0xDB(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial DCP Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_C|vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_AbsY(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
#endif
}
static int InstructionExecute_0xDC(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xDD(H_NES_Console* Console){
  //CMP Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0xDE(H_NES_Console* Console){
  //DEC Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_AbsX(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
}
static int InstructionExecute_0xDF(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial DCP Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usA;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_C|vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M-1U;
  usA=((Huint16)Console->CPU.Register.A)-M;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usA&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usA==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_AbsX(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
#endif
}

static int InstructionExecute_0xE0(H_NES_Console* Console){
  //CPX #Oper

  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usX;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,M);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usX=(Huint16)Console->CPU.Register.X-M;
  if(usX<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usX&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usX==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xE1(H_NES_Console* Console){
  //SBC (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPageX7(Console,LastPC,M,Zpg,Abs);

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0xE2(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial NOP*t

  return InstructionExecute_0x82(Console);
#endif
}
static int InstructionExecute_0xE3(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial ISB (Zpg,X)

  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPageX7(Console,LastPC,M,Zpg,Abs);

  M=M-1U;

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  oH_NES_CPU_M_Write_6ZeroPageX7(Console,M,Abs);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 8;
#endif
}
static int InstructionExecute_0xE4(H_NES_Console* Console){
  //CPX Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usX;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usX=(Huint16)Console->CPU.Register.X-M;
  if(usX<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usX&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usX==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0xE5(H_NES_Console* Console){
  //SBC Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 3;
}
static int InstructionExecute_0xE6(H_NES_Console* Console){
  //INC Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M+1U;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_ZeroPage(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5;
}
static int InstructionExecute_0xE7(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial ISB Zpg

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPage(Console,LastPC,M,Zpg);

  M=M-1U;

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  oH_NES_CPU_M_Write_ZeroPage(Console,M,Zpg);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5;
#endif
}
static int InstructionExecute_0xE8(H_NES_Console* Console){
  //INX

  Huint16 PC;
  Hbyte X;
  Hbyte P;

  X=Console->CPU.Register.X;
  P=Console->CPU.Register.P;
  PC=Console->CPU.Register.PC;

  PC=PC+1U;//下一条指令位置

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  X=X+1U;
  if((X&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(X==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.X=X;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xE9(H_NES_Console* Console){
  //SBC #Oper

  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Imm(Console,LastPC,M);

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xEA(H_NES_Console* Console){
  //NOP

  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置
  
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xEB(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xEC(H_NES_Console* Console){
  //CPX Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Huint16 usX;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  usX=(Huint16)Console->CPU.Register.X-M;
  if(usX<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((usX&0x0080U)!=0U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(usX==0U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xED(H_NES_Console* Console){
  //SBC Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xEE(H_NES_Console* Console){
  //INC Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M+1U;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_Abs(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0xEF(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial ISB Abs

  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_Abs(Console,LastPC,M,Abs);

  M=M-1U;

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  oH_NES_CPU_M_Write_Abs(Console,M,Abs);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
#endif
}

static int InstructionExecute_0xF0(H_NES_Console* Console){
  //BEQ Oper

  Huint16 ExtClock;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;

  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  ExtClock=0U;
  if((Console->CPU.Register.P&vH_NES_CPU_Register_P_Z)!=0U){
    LastPC++;
    oH_NES_CPU_ReadOpcode(Console,LastPC,M);
    LastPC=PC+M;
    if((M&0x80U)!=0U){
      LastPC+=0xFF00U;
    }
    if((LastPC&0xFF00U)!=(PC&0xFF00U)){
      ExtClock=2U;
    }else{
      ExtClock=1U;
    }
    PC=LastPC;
  }

  Console->CPU.Register.PC=PC;//更新PC

  return 2+ExtClock;
}
static int InstructionExecute_0xF1(H_NES_Console* Console){
  //SBC (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPage7Y(Console,LastPC,M,Zpg,Abs,ExtClock);

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 5+ExtClock;
}
static int InstructionExecute_0xF2(H_NES_Console* Console){
  //SBC (Zpg)

  return InstructionExecute_Unrealized(Console);
  // Hbyte Zpg;
  // Huint16 Abs;
  // Hbyte M;
  // Huint16 LastPC;
  // Huint16 PC;
  // Hbyte LastA;
  // Hbyte A;
  // Huint16 usA;
  // Hbyte P;

  // LastA=Console->CPU.Register.A;
  // P=Console->CPU.Register.P;
  // LastPC=Console->CPU.Register.PC;

  // PC=LastPC+2U;//下一条指令位置

  // LastPC++;
  // oH_NES_CPU_M_6ZeroPage7(Console,LastPC,M,Zpg,Abs);

  // usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  // P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  // A=(Hbyte)usA;
  // if(usA<0x0100U){
  //   P|=vH_NES_CPU_Register_P_C;
  // }
  // if((A&0x80U)!=0x00U){
  //   P|=vH_NES_CPU_Register_P_N;
  // }else{
  //   if(A==0x00U){
  //     P|=vH_NES_CPU_Register_P_Z;
  //   }
  // }
  // if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
  //   P|=vH_NES_CPU_Register_P_V;
  // }

  // Console->CPU.Register.A=A;
  // Console->CPU.Register.P=P;
  // Console->CPU.Register.PC=PC;//更新PC

  // return 5;
}
static int InstructionExecute_0xF3(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial ISB (Zpg),Y

  Huint16 ExtClock;
  Hbyte Zpg;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_6ZeroPage7Y(Console,LastPC,M,Zpg,Abs,ExtClock);

  M=M-1U;

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  oH_NES_CPU_M_Write_6ZeroPage7Y(Console,M,Abs);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 8;
#endif
}
static int InstructionExecute_0xF4(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xF5(H_NES_Console* Console){
  //SBC Zpg,X 

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4;
}
static int InstructionExecute_0xF6(H_NES_Console* Console){
  //INC Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M+1U;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_ZeroPageX(Console,M,Zpg);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
}
static int InstructionExecute_0xF7(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial ISB Zpg,X

  Hbyte Zpg;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+2U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_ZeroPageX(Console,LastPC,M,Zpg);

  M=M-1U;

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  oH_NES_CPU_M_Write_ZeroPageX(Console,M,Zpg);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 6;
#endif
}
static int InstructionExecute_0xF8(H_NES_Console* Console){
  //SED

  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+1U;//下一条指令位置

  P|=vH_NES_CPU_Register_P_D;

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 2;
}
static int InstructionExecute_0xF9(H_NES_Console* Console){
  //SBC Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,M,Abs,ExtClock);

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0xFA(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial NOP
  
  return InstructionExecute_0xEA(Console);
#endif
}
static int InstructionExecute_0xFB(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial ISB Abs,Y

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsY(Console,LastPC,M,Abs,ExtClock);

  M=M-1U;

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  oH_NES_CPU_M_Write_AbsY(Console,M,Abs);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
#endif
}
static int InstructionExecute_0xFC(H_NES_Console* Console){return InstructionExecute_Unrealized(Console);}
static int InstructionExecute_0xFD(H_NES_Console* Console){
  //SBC Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 4+ExtClock;
}
static int InstructionExecute_0xFE(H_NES_Console* Console){
  //INC Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte P;

  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_Z));
  M=M+1U;
  if((M&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(M==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }

  oH_NES_CPU_M_Write_AbsX(Console,M,Abs);

  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
}
static int InstructionExecute_0xFF(H_NES_Console* Console){

#if vH_NES_CPU_UseUnofficialOpcode == 0
  return InstructionExecute_Unrealized(Console);
#else
  //Unofficial ISB Abs,X

  Huint16 ExtClock;
  Huint16 Abs;
  Hbyte M;
  Huint16 LastPC;
  Huint16 PC;
  Hbyte LastA;
  Hbyte A;
  Huint16 usA;
  Hbyte P;

  LastA=Console->CPU.Register.A;
  P=Console->CPU.Register.P;
  LastPC=Console->CPU.Register.PC;

  PC=LastPC+3U;//下一条指令位置

  LastPC++;
  oH_NES_CPU_M_AbsX(Console,LastPC,M,Abs,ExtClock);

  M=M-1U;

  usA=(Huint16)LastA-M-((~P)&vH_NES_CPU_Register_P_C);
  P&=(~(vH_NES_CPU_Register_P_N|vH_NES_CPU_Register_P_V|vH_NES_CPU_Register_P_Z|vH_NES_CPU_Register_P_C));
  A=(Hbyte)usA;
  if(usA<0x0100U){
    P|=vH_NES_CPU_Register_P_C;
  }
  if((A&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_N;
  }else{
    if(A==0x00U){
      P|=vH_NES_CPU_Register_P_Z;
    }
  }
  if(((LastA^M)&(LastA^A)&0x80U)!=0x00U){
    P|=vH_NES_CPU_Register_P_V;
  }

  oH_NES_CPU_M_Write_AbsX(Console,M,Abs);

  Console->CPU.Register.A=A;
  Console->CPU.Register.P=P;
  Console->CPU.Register.PC=PC;//更新PC

  return 7;
#endif
}




//指令执行方法集合
static int (*InstructionExecute[256])(H_NES_Console*)={
  [0x00]=InstructionExecute_0x00,[0x01]=InstructionExecute_0x01,[0x02]=InstructionExecute_0x02,[0x03]=InstructionExecute_0x03,
  [0x04]=InstructionExecute_0x04,[0x05]=InstructionExecute_0x05,[0x06]=InstructionExecute_0x06,[0x07]=InstructionExecute_0x07,
  [0x08]=InstructionExecute_0x08,[0x09]=InstructionExecute_0x09,[0x0A]=InstructionExecute_0x0A,[0x0B]=InstructionExecute_0x0B,
  [0x0C]=InstructionExecute_0x0C,[0x0D]=InstructionExecute_0x0D,[0x0E]=InstructionExecute_0x0E,[0x0F]=InstructionExecute_0x0F,
  [0x10]=InstructionExecute_0x10,[0x11]=InstructionExecute_0x11,[0x12]=InstructionExecute_0x12,[0x13]=InstructionExecute_0x13,
  [0x14]=InstructionExecute_0x14,[0x15]=InstructionExecute_0x15,[0x16]=InstructionExecute_0x16,[0x17]=InstructionExecute_0x17,
  [0x18]=InstructionExecute_0x18,[0x19]=InstructionExecute_0x19,[0x1A]=InstructionExecute_0x1A,[0x1B]=InstructionExecute_0x1B,
  [0x1C]=InstructionExecute_0x1C,[0x1D]=InstructionExecute_0x1D,[0x1E]=InstructionExecute_0x1E,[0x1F]=InstructionExecute_0x1F,
  [0x20]=InstructionExecute_0x20,[0x21]=InstructionExecute_0x21,[0x22]=InstructionExecute_0x22,[0x23]=InstructionExecute_0x23,
  [0x24]=InstructionExecute_0x24,[0x25]=InstructionExecute_0x25,[0x26]=InstructionExecute_0x26,[0x27]=InstructionExecute_0x27,
  [0x28]=InstructionExecute_0x28,[0x29]=InstructionExecute_0x29,[0x2A]=InstructionExecute_0x2A,[0x2B]=InstructionExecute_0x2B,
  [0x2C]=InstructionExecute_0x2C,[0x2D]=InstructionExecute_0x2D,[0x2E]=InstructionExecute_0x2E,[0x2F]=InstructionExecute_0x2F,
  [0x30]=InstructionExecute_0x30,[0x31]=InstructionExecute_0x31,[0x32]=InstructionExecute_0x32,[0x33]=InstructionExecute_0x33,
  [0x34]=InstructionExecute_0x34,[0x35]=InstructionExecute_0x35,[0x36]=InstructionExecute_0x36,[0x37]=InstructionExecute_0x37,
  [0x38]=InstructionExecute_0x38,[0x39]=InstructionExecute_0x39,[0x3A]=InstructionExecute_0x3A,[0x3B]=InstructionExecute_0x3B,
  [0x3C]=InstructionExecute_0x3C,[0x3D]=InstructionExecute_0x3D,[0x3E]=InstructionExecute_0x3E,[0x3F]=InstructionExecute_0x3F,
  [0x40]=InstructionExecute_0x40,[0x41]=InstructionExecute_0x41,[0x42]=InstructionExecute_0x42,[0x43]=InstructionExecute_0x43,
  [0x44]=InstructionExecute_0x44,[0x45]=InstructionExecute_0x45,[0x46]=InstructionExecute_0x46,[0x47]=InstructionExecute_0x47,
  [0x48]=InstructionExecute_0x48,[0x49]=InstructionExecute_0x49,[0x4A]=InstructionExecute_0x4A,[0x4B]=InstructionExecute_0x4B,
  [0x4C]=InstructionExecute_0x4C,[0x4D]=InstructionExecute_0x4D,[0x4E]=InstructionExecute_0x4E,[0x4F]=InstructionExecute_0x4F,
  [0x50]=InstructionExecute_0x50,[0x51]=InstructionExecute_0x51,[0x52]=InstructionExecute_0x52,[0x53]=InstructionExecute_0x53,
  [0x54]=InstructionExecute_0x54,[0x55]=InstructionExecute_0x55,[0x56]=InstructionExecute_0x56,[0x57]=InstructionExecute_0x57,
  [0x58]=InstructionExecute_0x58,[0x59]=InstructionExecute_0x59,[0x5A]=InstructionExecute_0x5A,[0x5B]=InstructionExecute_0x5B,
  [0x5C]=InstructionExecute_0x5C,[0x5D]=InstructionExecute_0x5D,[0x5E]=InstructionExecute_0x5E,[0x5F]=InstructionExecute_0x5F,
  [0x60]=InstructionExecute_0x60,[0x61]=InstructionExecute_0x61,[0x62]=InstructionExecute_0x62,[0x63]=InstructionExecute_0x63,
  [0x64]=InstructionExecute_0x64,[0x65]=InstructionExecute_0x65,[0x66]=InstructionExecute_0x66,[0x67]=InstructionExecute_0x67,
  [0x68]=InstructionExecute_0x68,[0x69]=InstructionExecute_0x69,[0x6A]=InstructionExecute_0x6A,[0x6B]=InstructionExecute_0x6B,
  [0x6C]=InstructionExecute_0x6C,[0x6D]=InstructionExecute_0x6D,[0x6E]=InstructionExecute_0x6E,[0x6F]=InstructionExecute_0x6F,
  [0x70]=InstructionExecute_0x70,[0x71]=InstructionExecute_0x71,[0x72]=InstructionExecute_0x72,[0x73]=InstructionExecute_0x73,
  [0x74]=InstructionExecute_0x74,[0x75]=InstructionExecute_0x75,[0x76]=InstructionExecute_0x76,[0x77]=InstructionExecute_0x77,
  [0x78]=InstructionExecute_0x78,[0x79]=InstructionExecute_0x79,[0x7A]=InstructionExecute_0x7A,[0x7B]=InstructionExecute_0x7B,
  [0x7C]=InstructionExecute_0x7C,[0x7D]=InstructionExecute_0x7D,[0x7E]=InstructionExecute_0x7E,[0x7F]=InstructionExecute_0x7F,
  [0x80]=InstructionExecute_0x80,[0x81]=InstructionExecute_0x81,[0x82]=InstructionExecute_0x82,[0x83]=InstructionExecute_0x83,
  [0x84]=InstructionExecute_0x84,[0x85]=InstructionExecute_0x85,[0x86]=InstructionExecute_0x86,[0x87]=InstructionExecute_0x87,
  [0x88]=InstructionExecute_0x88,[0x89]=InstructionExecute_0x89,[0x8A]=InstructionExecute_0x8A,[0x8B]=InstructionExecute_0x8B,
  [0x8C]=InstructionExecute_0x8C,[0x8D]=InstructionExecute_0x8D,[0x8E]=InstructionExecute_0x8E,[0x8F]=InstructionExecute_0x8F,
  [0x90]=InstructionExecute_0x90,[0x91]=InstructionExecute_0x91,[0x92]=InstructionExecute_0x92,[0x93]=InstructionExecute_0x93,
  [0x94]=InstructionExecute_0x94,[0x95]=InstructionExecute_0x95,[0x96]=InstructionExecute_0x96,[0x97]=InstructionExecute_0x97,
  [0x98]=InstructionExecute_0x98,[0x99]=InstructionExecute_0x99,[0x9A]=InstructionExecute_0x9A,[0x9B]=InstructionExecute_0x9B,
  [0x9C]=InstructionExecute_0x9C,[0x9D]=InstructionExecute_0x9D,[0x9E]=InstructionExecute_0x9E,[0x9F]=InstructionExecute_0x9F,
  [0xA0]=InstructionExecute_0xA0,[0xA1]=InstructionExecute_0xA1,[0xA2]=InstructionExecute_0xA2,[0xA3]=InstructionExecute_0xA3,
  [0xA4]=InstructionExecute_0xA4,[0xA5]=InstructionExecute_0xA5,[0xA6]=InstructionExecute_0xA6,[0xA7]=InstructionExecute_0xA7,
  [0xA8]=InstructionExecute_0xA8,[0xA9]=InstructionExecute_0xA9,[0xAA]=InstructionExecute_0xAA,[0xAB]=InstructionExecute_0xAB,
  [0xAC]=InstructionExecute_0xAC,[0xAD]=InstructionExecute_0xAD,[0xAE]=InstructionExecute_0xAE,[0xAF]=InstructionExecute_0xAF,
  [0xB0]=InstructionExecute_0xB0,[0xB1]=InstructionExecute_0xB1,[0xB2]=InstructionExecute_0xB2,[0xB3]=InstructionExecute_0xB3,
  [0xB4]=InstructionExecute_0xB4,[0xB5]=InstructionExecute_0xB5,[0xB6]=InstructionExecute_0xB6,[0xB7]=InstructionExecute_0xB7,
  [0xB8]=InstructionExecute_0xB8,[0xB9]=InstructionExecute_0xB9,[0xBA]=InstructionExecute_0xBA,[0xBB]=InstructionExecute_0xBB,
  [0xBC]=InstructionExecute_0xBC,[0xBD]=InstructionExecute_0xBD,[0xBE]=InstructionExecute_0xBE,[0xBF]=InstructionExecute_0xBF,
  [0xC0]=InstructionExecute_0xC0,[0xC1]=InstructionExecute_0xC1,[0xC2]=InstructionExecute_0xC2,[0xC3]=InstructionExecute_0xC3,
  [0xC4]=InstructionExecute_0xC4,[0xC5]=InstructionExecute_0xC5,[0xC6]=InstructionExecute_0xC6,[0xC7]=InstructionExecute_0xC7,
  [0xC8]=InstructionExecute_0xC8,[0xC9]=InstructionExecute_0xC9,[0xCA]=InstructionExecute_0xCA,[0xCB]=InstructionExecute_0xCB,
  [0xCC]=InstructionExecute_0xCC,[0xCD]=InstructionExecute_0xCD,[0xCE]=InstructionExecute_0xCE,[0xCF]=InstructionExecute_0xCF,
  [0xD0]=InstructionExecute_0xD0,[0xD1]=InstructionExecute_0xD1,[0xD2]=InstructionExecute_0xD2,[0xD3]=InstructionExecute_0xD3,
  [0xD4]=InstructionExecute_0xD4,[0xD5]=InstructionExecute_0xD5,[0xD6]=InstructionExecute_0xD6,[0xD7]=InstructionExecute_0xD7,
  [0xD8]=InstructionExecute_0xD8,[0xD9]=InstructionExecute_0xD9,[0xDA]=InstructionExecute_0xDA,[0xDB]=InstructionExecute_0xDB,
  [0xDC]=InstructionExecute_0xDC,[0xDD]=InstructionExecute_0xDD,[0xDE]=InstructionExecute_0xDE,[0xDF]=InstructionExecute_0xDF,
  [0xE0]=InstructionExecute_0xE0,[0xE1]=InstructionExecute_0xE1,[0xE2]=InstructionExecute_0xE2,[0xE3]=InstructionExecute_0xE3,
  [0xE4]=InstructionExecute_0xE4,[0xE5]=InstructionExecute_0xE5,[0xE6]=InstructionExecute_0xE6,[0xE7]=InstructionExecute_0xE7,
  [0xE8]=InstructionExecute_0xE8,[0xE9]=InstructionExecute_0xE9,[0xEA]=InstructionExecute_0xEA,[0xEB]=InstructionExecute_0xEB,
  [0xEC]=InstructionExecute_0xEC,[0xED]=InstructionExecute_0xED,[0xEE]=InstructionExecute_0xEE,[0xEF]=InstructionExecute_0xEF,
  [0xF0]=InstructionExecute_0xF0,[0xF1]=InstructionExecute_0xF1,[0xF2]=InstructionExecute_0xF2,[0xF3]=InstructionExecute_0xF3,
  [0xF4]=InstructionExecute_0xF4,[0xF5]=InstructionExecute_0xF5,[0xF6]=InstructionExecute_0xF6,[0xF7]=InstructionExecute_0xF7,
  [0xF8]=InstructionExecute_0xF8,[0xF9]=InstructionExecute_0xF9,[0xFA]=InstructionExecute_0xFA,[0xFB]=InstructionExecute_0xFB,
  [0xFC]=InstructionExecute_0xFC,[0xFD]=InstructionExecute_0xFD,[0xFE]=InstructionExecute_0xFE,[0xFF]=InstructionExecute_0xFF
};
unsigned short debugopcodeindex=0;
unsigned short debugCode[256]={0};
unsigned char debugCodeArray[256]={0};


static int InstructionStep(H_NES_Console* Console){
  Huint16 PC;
  Hbyte SP;
  Hbyte P;
  Hbyte* Stack;
  Hbyte Opcode;

  Huint16 Status;
  Huint16 Address;
  Huint16 Index;


  Status=Console->CPU.Status;
  if(Status!=0U){

    //检查 OAM DMA
    if((Status&vH_NES_CPU_Status_DMA)!=0U){
      Address=Console->CPU.DMA.OAMADDR;
      oH_NES_CPU_Read(Console,Address,Opcode);
      Index=Address&0x00FFU;
      Console->PPU.OAM[Index]=Opcode;
      if(Index==0x00FFU){
        Console->CPU.Status=Status&(~vH_NES_CPU_Status_DMA);
      }else{
        Console->CPU.DMA.OAMADDR=Address+0x0001U;
      }

      return 2;
    }

    
    if((Status&vH_NES_CPU_Status_NMI_Suspend)!=0U){
      //NMI
      Console->CPU.Status=Status&(~vH_NES_CPU_Status_NMI_Suspend);

      P=Console->CPU.Register.P;
      SP=Console->CPU.Register.S;
      PC=Console->CPU.Register.PC;
      Stack=&((Hbyte*)Console->CPU.Bus.RAM)[0x100];

      Stack[SP]=(Hbyte)(PC>>8);
      Stack[SP-(Hbyte)1U]=(Hbyte)PC;
      Stack[SP-(Hbyte)2U]=P|vH_NES_CPU_Register_P_NMI;
      SP-=3;

      P|=vH_NES_CPU_Register_P_I;

      PC=Console->Cartridge.PRG_Read16(vH_NES_CPU_NMIVector,Console);//中断向量地址读取

      Console->CPU.Register.P=P;
      Console->CPU.Register.S=SP;
      Console->CPU.Register.PC=PC;//更新PC

      return 7;
    }else
    if((Status&(vH_NES_CPU_Status_IRQ_Msk))!=0U){
      P=Console->CPU.Register.P;
      if((P&vH_NES_CPU_Register_P_I)==0U){
        //IRQ
        SP=Console->CPU.Register.S;
        PC=Console->CPU.Register.PC;
        Stack=&((Hbyte*)Console->CPU.Bus.RAM)[0x100];

        Stack[SP]=(Hbyte)(PC>>8);
        Stack[SP-(Hbyte)1U]=(Hbyte)PC;
        Stack[SP-(Hbyte)2U]=P|vH_NES_CPU_Register_P_IRQ;
        SP-=3;

        P|=vH_NES_CPU_Register_P_I;

        PC=Console->Cartridge.PRG_Read16(vH_NES_CPU_IRQVector,Console);//中断向量地址读取

        Console->CPU.Register.P=P;
        Console->CPU.Register.S=SP;
        Console->CPU.Register.PC=PC;//更新PC

        return 7;
      }
    }

  }


  PC=Console->CPU.Register.PC;
  oH_NES_CPU_ReadOpcode(Console,PC,Opcode);//读取下一条操作码
  if(debugCode[Opcode]==0U){
    debugCodeArray[debugopcodeindex]=Opcode;
    debugCode[Opcode]=debugopcodeindex++;
  };
  return InstructionExecute[Opcode](Console);
}




void H_NES_CPU_Reset(H_NES_Console* Console){
  Huint16 PC;

  Console->CPU.MCLK=0;
  Console->CPU.APU_Clock=0;
  Console->CPU.Register.P=vH_NES_CPU_Register_P_I;
  Console->CPU.Status=0U;

  PC=Console->Cartridge.PRG_Read16(vH_NES_CPU_ResetVector,Console);
  Console->CPU.Register.PC=PC;

}

void H_NES_CPU_Execute_NTSC(Hint32 MCLK,H_NES_Console* Console){
  Hbyte APU_Clock;
  Hint t;

  MCLK+=Console->CPU.MCLK;

  if(MCLK>0){
    APU_Clock=Console->CPU.APU_Clock;

    while(MCLK>0){
      t=InstructionStep(Console);
      APU_Clock+=t;
      MCLK-=t*vH_NES_CPU_NTSC_MCLKDiv;

      while(APU_Clock>3){
        APU_Clock-=4;
        H_NES_APU_Process(Console);
      }
    }
    
    Console->CPU.APU_Clock=APU_Clock;
  }
  Console->CPU.MCLK=MCLK;

}
void H_NES_CPU_Execute_PAL(Hint32 MCLK,H_NES_Console* Console){
  Hbyte APU_Clock;
  Hint t;

  MCLK+=Console->CPU.MCLK;

  if(MCLK>0){
    APU_Clock=Console->CPU.APU_Clock;

    while(MCLK>0){
      t=InstructionStep(Console);
      APU_Clock+=t;
      MCLK-=t*vH_NES_CPU_PAL_MCLKDiv;

      while(APU_Clock>3){
        APU_Clock-=4;
        H_NES_APU_Process(Console);
      }
    }

    Console->CPU.APU_Clock=APU_Clock;
  }
  Console->CPU.MCLK=MCLK;

}
void H_NES_CPU_Execute_Dendy(Hint32 MCLK,H_NES_Console* Console){
  Hbyte APU_Clock;
  Hint t;

  MCLK+=Console->CPU.MCLK;

  if(MCLK>0){
    APU_Clock=Console->CPU.APU_Clock;

    while(MCLK>0){
      t=InstructionStep(Console);
      APU_Clock+=t;
      MCLK-=t*vH_NES_CPU_Dendy_MCLKDiv;

      while(APU_Clock>3){
        APU_Clock-=4;
        H_NES_APU_Process(Console);
      }
    }

    Console->CPU.APU_Clock=APU_Clock;
  }
  Console->CPU.MCLK=MCLK;

}



